<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 甲乙丙丁戊己庚戌壬癸 -->
    <script>
      const str = "甲乙丙丁戊己庚戌壬癸";
      const arr = ["丁", "甲", "乙", "壬", "己", "壬", "庚", "癸"];
      arr.sort((a, b) => str.indexOf(a) - str.indexOf(b));
      console.log(arr);
    </script>
  </body>
</html>
